﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DAL;
using DTO;

namespace WEBSITE_BANDEAL.Admin
{
    public partial class LoaiSP_List : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lit_title.Text = "Quản lý loại sản phẩm";
            lit_title_header.Text = "Danh sách loại sản phẩm";
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            Loaisanphamcollection lsp = LOAI_SAN_PHAMBUS.GetAll();
            Repeater1.DataSource = lsp;
            Repeater1.DataBind();
        }

        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {


               //Literal lit_Ma = (Literal)e.Item.FindControl("lit_Ma");
                Literal lit_trangthai = (Literal)e.Item.FindControl("lit_trangthai");
                Literal lit_tencha = (Literal)e.Item.FindControl("lit_tencha");
                LOAI_SANPHAM lsp = (LOAI_SANPHAM)e.Item.DataItem;
                lit_tencha.Text = LOAI_SAN_PHAMBUS.GetCha(lsp.Maloaicha);
                if(lsp.Trangthai==1)
                {
                    lit_trangthai.Text = " <img src='../Template/images/admin/check.png' alt='"+ lsp.Maloai.ToString()+"' onClick='AnHien("+ lsp.Maloai+")' title='Hiện' style='margin:10px;cursor:pointer;'  />";
                }
                else
                {
                    lit_trangthai.Text = "<img src='../Template/images/admin/cancel.png' alt='" + lsp.Maloai.ToString() + "' onClick='AnHien(" + lsp.Maloai + ")' title='Ẩn' style='margin:10px;cursor:pointer;' />";
                }


            }
        }
    }
}